/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package TreeView;

/**
 *
 * @author Mr.Sam
 */
import java.awt.*;
import java.awt.event.*;
import fr.ove.openmath.jome.model.*;
import fr.ove.openmath.jome.model.events.*;
import fr.ove.openmath.jome.ctrl.linear.*;

public class FormulaTreeViewer extends Frame {
    Formula formula;
    ScrollPane sp;
    View display;
    
    public FormulaTreeViewer(Formula formula) {
        setLayout(new BorderLayout());
        setBounds(50, 50, 500, 300);
        sp = new ScrollPane();
        add("Center", sp);
        
        this.formula = formula;
	    display = new View();
        display.tick.setTickType(TreeTick.NONE);
        
        String prop = "FORMULA  --[ ";
        prop += "Strahler = " + formula.getNbStrahler();
        prop += ", Depth = " + formula.getDepth();
        prop += ", Width = " + formula.getNbChildren();
        prop += " ]";
	    display.setProperties(prop);
	    
	    formula.addModelListener(display);
	    display.buildDisplay(formula);
	    
        Panel innerPanel = new Panel();
        innerPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
	    innerPanel.add(display);
	    sp.add(innerPanel);
	    
    	addWindowListener(
		    new WindowAdapter() {
        		public void windowClosing(WindowEvent event) {
        		    event.getWindow().dispose();
        		}
        	}
        );
	    setVisible(true);
    }
}